<template>
  <a-modal
    :title="title"
    :width="1000"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >

  <div>

  </div>

  </a-modal>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'

const path = '/sys/user'
import { httpAction } from '@/api/manage'
import JEditor from '@/components/jeecg/JEditor'
import JSwitch from '@/components/jeecg/JSwitch'


export default {

  mixins: [JeecgListMixin],
  name: 'UserSelectModal',
  components: {
    JEditor,
    JSwitch
  },
  data() {
    return {
      dataSource1:[],
      userName: '',
      workShop: undefined,
      selectNumber: '1',
      title: '操作',
      visible: false,
      disable: true,
      model: {},
      confirmLoading: false,
      form: this.$form.createForm(this),
      columns: [
        {
          title: '姓名',
          align: 'center',
          width: 80,
          dataIndex: 'realname',
          ellipsis: true
        },
        {
          title: '性别',
          align: 'center',
          width: 80,
          dataIndex: 'sex_dictText',
          ellipsis: true
        },
        {
          title: '工号',
          align: 'center',
          width: 80,
          dataIndex: 'workNo',
          ellipsis: true
        },
        // {
        //   title: '车间',
        //   align: 'center',
        //   width: 80,
        //   dataIndex: 'post',
        //   ellipsis: true
        // },
        // {
        //   title: '工序',
        //   align: 'center',
        //   width: 80,
        //   dataIndex: 'post',
        //   ellipsis: true
        // },
        {
          title: '工种',
          align: 'center',
          width: 80,
          dataIndex: 'post',
          ellipsis: true
        },
        // {
        //   title: '班次',
        //   align: 'center',
        //   width: 80,
        //   dataIndex: 'ingot',
        //   ellipsis: true,
        //   scopedSlots: { customRender: 'ingot' },
        // }
      ],
      url: {
        list: path + '/list',
        delete: path + '/delete',
        deleteBatch: path + '/deleteBatch',
        toDetail: '/personnelInformation/modules/blacklistDetails'
      }
    }
  },
  created() {
  },
  mounted() {

  },
  methods: {
    onSelect(selectedKeys, info) {
      console.log('selected', selectedKeys, info)
    },
    handleChange(value) {
      console.log(`selected ${value}`)
    },
    onCheck(checkedKeys, info) {
      console.log('onCheck', checkedKeys, info)
    },
    add() {
      this.disable = false
      this.model = Object.assign({}, { workingProcedure: 1 })
      this.model.workingProcedure = 1
      this.edit({}, 1)
      // let query = {
      //   column: 'createTime',
      //   order: 'desc',
      //   field: "id,username,realname,avatar,sex_dictText,birthday,phone,orgCodeTxt,departIds_dictText,status_dictText,action"
      // }
      // getUser(query).then((res) => {
      //   if (res.success) {
      //     this.dataSource1 = res.data.result.records
      //   } else {
      //     that.$message.warning(res.message)
      //   }
      // })
    },
    edit(record, isEdit) {
      if (isEdit != 1) {
        this.model = Object.assign({}, record)
      }

      this.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.disable = true
    },

    handleOk() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.confirmLoading = true
          let httpurl = ''
          let method = ''
          if (!this.model.id) {
            httpurl += this.url.add
            method = 'post'
          } else {
            httpurl += this.url.edit
            method = 'put'
          }
          let formData = Object.assign(this.model)
          console.log('formData', formData)
          //时间格式化
          httpAction(httpurl, formData, method)
            .then(res => {
              if (res.success) {
                this.$message.success(res.message)
                this.$emit('ok')
              } else {
                this.$message.warning(res.message)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
            })
        } else {
          return false
        }
      })
    },
    onChangePage(e) {
      this.ipagination.current = e
      this.loadData()
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style scoped></style>
